Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

fflate

Package Overview
Dependencies
Maintainers
1
Versions
53
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fflate

High performance (de)compression in an 8kB package

  • 0.8.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
6.1M
increased by2.97%
Maintainers
1
Weekly downloads
 
Created

What is fflate?

The fflate npm package is a JavaScript library for performing various compression and decompression operations. It is designed to be fast and efficient, leveraging modern algorithms and techniques to handle ZIP, GZIP, and Zlib formats.

What are fflate's main functionalities?

Compression

This feature allows you to compress data using the deflate algorithm. The code sample demonstrates how to compress a Uint8Array of data.

const fflate = require('fflate');
const { deflate } = fflate;
const uncompressed = new Uint8Array([/* some data */]);
const compressed = deflate(uncompressed);

Decompression

This feature allows you to decompress data that was compressed using the deflate algorithm. The code sample shows how to decompress a Uint8Array of compressed data.

const fflate = require('fflate');
const { inflate } = fflate;
const compressed = new Uint8Array([/* some compressed data */]);
const decompressed = inflate(compressed);

ZIP File Creation

This feature allows you to create ZIP files. The code sample demonstrates how to zip multiple files represented as Uint8Arrays into a single ZIP file.

const fflate = require('fflate');
const { zip } = fflate;
const files = {
  'file.txt': new Uint8Array([/* file data */]),
  'another.txt': new Uint8Array([/* more file data */])
};
zip(files, (err, zipped) => {
  if (!err) console.log(zipped);
});

ZIP File Extraction

This feature allows you to extract files from a ZIP archive. The code sample shows how to unzip a Uint8Array of zipped data to retrieve the original files.

const fflate = require('fflate');
const { unzip } = fflate;
const zipData = new Uint8Array([/* some zipped data */]);
unzip(zipData, (err, unzipped) => {
  if (!err) console.log(unzipped);
});

Stream Compression and Decompression

This feature allows you to perform stream-based compression and decompression, which is useful for handling large datasets or files. The code sample demonstrates how to use the Deflate and Inflate classes to compress and decompress data in a streaming manner.

const fflate = require('fflate');
const { Deflate, Inflate } = fflate;
const deflateStream = new Deflate();
deflateStream.push(new Uint8Array([/* some data */]), true);
const compressed = deflateStream.result;
const inflateStream = new Inflate();
inflateStream.push(compressed, true);
const decompressed = inflateStream.result;

Other packages similar to fflate

Keywords

FAQs

Package last updated on 07 Feb 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc